package com.tledu.io;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class IO05 {
    public static void main(String[] args) {
        String fileName = "C:\\Users\\cyrus\\Desktop\\大数据17期\\study-java\\src\\com\\tledu\\io\\test";
        BufferedInputStream bufferedIn = null;
        try {
            bufferedIn = new BufferedInputStream(new FileInputStream(fileName));
            byte[] bytes = new byte[512];
            // 会有一个返回值，返回就是这次读取的数据的个数
            int num;
            while ((num = bufferedIn.read(bytes)) !=-1) {
//                int num = bufferedIn.read(bytes);
//                if (num == -1) {
//                    break;
//                }
                System.out.print(new String(bytes,0,num,"UTF8"));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                bufferedIn.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
